#!/usr/bin/python
# vim: set fileencoding=utf-8:  
import urllib2
from bs4 import BeautifulSoup

page = urllib2.urlopen("http://lives.sina.cn/event/?channel=finance&topic=globalnews1?tag=&refreshtime=60&fromsinago=0&vt=4&page=1")
soup = BeautifulSoup(page)
for incident in soup('p'):
    what = incident.contents[0]
    str = what.strip()
    if str.find(u"美国和古巴") != -1:
	print str
#!/usr/bin/env python
#coding:utf8
# Import smtplib for the actual sending function
import smtplib
#第一封邮件
# Import the email modules we'll need
from email.mime.text import MIMEText
# Open a plain text file for reading.  For this example, assume that
# the text file contains only ASCII characters.
textfile='sendmail.py.html'
fp = open(textfile, 'rb')
# Create a text/plain message
msg = MIMEText(fp.read(),'html','utf8') #这是正确显示Html中文的设置，会解析html标签，不再是原始文本。
msg.set_charset('utf8')#这是正确显示中文的设置
fp.close()
username = 'yeaxxx@163.com'# the sender's email address
qq_mail = '411486203@qq.com'# the recipient's email address
msg['Subject'] = 'The contents of %s,中文标题' % textfile
msg['From'] = username 
msg['To'] = qq_mail
# Send the message via our own SMTP server, but don't include the
# envelope header.
s = smtplib.SMTP('smtp.163.com')
s.login("yeaxxx@163.com",'lsb450321')
s.sendmail(username , [qq_mail], msg.as_string())
s.quit()
